function counts(id){
	var w=window.event;
	$.post('counts.php', {'id':id});
}

/*
导航栏js代码开始
*/
var timeout         = 200;
var closetimer		= 0;
var ddmenuitem      = 0;
// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
// close layer when click-out
document.onclick = mclose;
/*
导航栏js代码结束
*/




function do_search() {
	$.get('utf2gbk.php?w='+$('#search .text').val(),dataType='text', function(data,status){
		location.href="http://haitaochaoshi.taobao.com/search.htm?search=y&keyword="+data+"&lowPrice=&highPrice=";
	});
	return false;
}

function keycheck() {
	if(event.keyCode==13)
    {
        do_search();
    }
}

$(document).ready(function(){
    $("#slides").slides({
    preloadImage:'http://img03.taobaocdn.com/imgextra/i3/135326559/T2cDbgXjhbXXXXXXXX_!!135326559.gif',
	play: 5000,    
	navigation: {
            active: true,
        // [boolean] Generates next and previous buttons.
        // You can set to false and use your own buttons.
        // User defined buttons must have the following:
        // previous button: class="slidesjs-previous slidesjs-navigation"
        // next button: class="slidesjs-next slidesjs-navigation"
            effect: "slide"
        // [string] Can be either "slide" or "fade".
        }
    });    
	
    var $container = $('#product');
    //$container.imagesLoaded( function(){
      $container.masonry({
        itemSelector : '.col',
        gutterWidth : 10,
        columnWidth : 230,
        isFitWidth : true
      });
    //});
    
    $container.infinitescroll({
      navSelector  : '#page-nav',    // selector for the paged navigation 
      nextSelector : '#page-nav a',  // selector for the NEXT link (to page 2)
      itemSelector : '.col',     // selector for all items you'll retrieve
		 
	    loading: {
          finishedMsg: '哎呦！！没有更多的商品了',
          img: 'http://img04.taobaocdn.com/imgextra/i4/135326559/T2YKUjXh4aXXXXXXXX_!!135326559.gif',
       	  msgText : '正在获取更多的商品',
        }
      },
      // trigger Masonry as a callback
      function( newElements ) {
        // hide new items while they are loading
        var $newElems = $( newElements );//.css({ opacity: 0 });
        // ensure that images load before adding to masonry layout
       /* $newElems.imagesLoaded(function(){
          // show elems now they're ready
          $newElems.animate({ opacity: 1 });
          $container.masonry( 'appended', $newElems, true ); 
        });*/
		$container.masonry( 'appended', $newElems, true );
      }
    );
});
